import { Component, Input } from '@angular/core';
import { FieldMapConfig } from 'src/components/scenarios/models';

@Component({
  selector: 'app-status-info',
  templateUrl: './status-info.component.html',
  styleUrl: './status-info.component.scss'
})
export class StatusInfoComponent {
  _cfg: FieldMapConfig = {
    Id: "",
    Name: "",
    Maps: [],
    FontSize: 12,
    Visible: true
  };

  @Input()
  status?: number;

  get statusColor() {
    const item = this._cfg.Maps.find(a => a.Key == this.status);
    if (item) {
      return item.Color;
    }
    return "";
  }
  get statusDescription() {
    const item = this._cfg.Maps.find(a => a.Key == this.status);
    if (item) {
      return item.Description;
    }
    return "";
  }

  @Input()
  get config() {
    return this._cfg;
  }
  set config(cfg: FieldMapConfig) {
    if (!cfg) {
      this._cfg = {
        Id: "",
        Name: "",
        Maps: [],
        FontSize: 12,
        Visible: true
      };
    } else {
      this._cfg = cfg;
    }
  }

}
